<template>
  <div class="app-container">
    <Search-content :queryParams="queryParams" labelWidth="120px" @query="handleQuery" @reset="resetQuery">
      <el-col :span="6">
        <el-form-item label="车牌号:">
          <el-input v-model="queryParams.carNo" clearable placeholder="请输入车牌号"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="车架号:">
          <el-input v-model="queryParams.vinNo" clearable placeholder="请输入车架号"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="品牌/车系/车型:">
          <linkage-select @changeNode="linkageChange" v-model="linkageList" placeholder="请选择品牌/车系/车型"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="客户名称:">
          <el-input v-model="queryParams.customerName" clearable placeholder="请输入客户名称"/>
        </el-form-item>
      </el-col>

      <el-col :span="6">
        <el-form-item label="车辆产权城市:">
          <el-input v-model="queryParams.vinNo" clearable placeholder="请输入车辆产权城市"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="关联订单:">
          <el-input v-model="queryParams.orderNo" clearable placeholder="请输入关联订单"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="产品方案:">
          <el-input v-model="queryParams.vinNo" clearable placeholder="请输入产品方案"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="产品方案:">
          <el-input v-model="queryParams.vinNo" clearable placeholder="请输入产品方案"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="创建人:">
          <el-input v-model="queryParams.vinNo" clearable placeholder="请输入创建人"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="申请时间:">
          <el-date-picker v-model="valueDate" type="daterange" placeholder="请选择日期" range-separator="-"
                          start-placeholder="开始日期" end-placeholder="结束日期" style="width: 100%;"/>
        </el-form-item>
      </el-col>
    </Search-content>

    <div class="card-wrap card-padding">
      <div class="table-title-wrap justify-end">
        <el-button size="mini" @click="handleNew"
                   v-hasPermi="['purchaseHandle:purchaseHandleList:new']" type="primary">
          新增申请
        </el-button>

        <el-button size="mini" type="primary" @click="handleDerive(row, 'derive')"
                   v-hasPermi="['purchaseHandle:purchaseHandleList:derive']">
          导出
        </el-button>
      </div>

      <table-page :loading="loading" :dataList="dataList" :total="total" :page.sync="queryParams.pageNum"
                  :limit.sync="queryParams.pageSize" @setSizeCurrent="handleList" border>

        <template slot="tableColAc">
          <el-table-column label="操作" align="center" fixed="left" width="100">
            <template #default="{row}">
              <el-button size="mini" type="text" @click="handleView(row, 'view')"
                         v-hasPermi="['purchaseHandle:purchaseHandleList:view']">
                查看
              </el-button>


            </template>
          </el-table-column>

        </template>

        <template slot="tableCol">
          <el-table-column align="center" label="租购过户编号" min-width="180" show-overflow-tooltip
                           prop="leasePurchaseTransferNo"/>

          <el-table-column align="center" label="车牌号" min-width="140" show-overflow-tooltip prop="carNo"/>

          <el-table-column align="center" label="客户名称" min-width="140" show-overflow-tooltip prop="customerName"/>

          <el-table-column align="center" label="车架号" min-width="180" show-overflow-tooltip prop="vinNo"/>

          <el-table-column  label="品牌/车型/车款" show-overflow-tooltip min-width="400">
            <template #default="{row}">
              {{ row.brandName }}{{ row.modelName ? '/' + row.modelName : '' }}
            </template>
          </el-table-column>

          <el-table-column align="center" label="车辆产权公司" show-overflow-tooltip min-width="160"
                           prop="propertyRightName"/>

          <el-table-column align="center" label="车辆归属公司" show-overflow-tooltip min-width="160" prop="ascription"/>

          <el-table-column align="center" label="审核节点" show-overflow-tooltip min-width="130"
                           prop="compulsoryStartTime">
            <template #default="{row}">
              {{ row.auditTask }}
            </template>
          </el-table-column>

          <el-table-column align="center" label="审核状态" show-overflow-tooltip min-width="130"
                           prop="compulsoryStartTime">
            <template #default="{row}">
              {{ row.auditStatus }}
            </template>
          </el-table-column>

          <el-table-column align="center" label="关联订单" show-overflow-tooltip min-width="100"
                           prop="orderNo"/>

          <el-table-column align="center" label="产品方案" show-overflow-tooltip min-width="120"
                           prop="compulsoryShouldAmortization"/>

          <el-table-column align="center" label="创建人" show-overflow-tooltip min-width="100"
                           prop="compulsoryWaitAmortization"/>

          <el-table-column align="center" label="创建时间" show-overflow-tooltip min-width="120">
            <template #default="{row}">
              {{ row.commercialStartTime ? $dayjs(row.commercialStartTime).format('YYYY-MM-DD') : '' }}
            </template>
          </el-table-column>

        </template>
      </table-page>
    </div>


  </div>
</template>

<script>
import LinkageSelect from "@/views/components/linkageSelect.vue";
import SearchContent from "@/components/SearchContent/index.vue";
import * as apis from '@/api/vehicleDisposal/purchaseHandle.js'

export default {
  name: 'PurchaseHandleList',//租购过户处理
  components: {SearchContent, LinkageSelect},
  watch: {},
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        amortizationMonth: "",
        commercialInsuranceStatus: "",
        compulsoryInsuranceStatus: "",
      },
      linkageList: [],
      dataList: [],
      total: 0,
      loading: false,
      valueDate: [],
    };
  },
  created() {
    this.handleList()
  },
  mounted() {
  },
  methods: {
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.handleList();
    },

    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        amortizationMonth: "",
        commercialInsuranceStatus: "",
        compulsoryInsuranceStatus: "",
      };
      this.handleList();
    },

    linkageChange(val) {
      this.linkageList = val;
      if (val) {
        this.queryParams.brandName = val[0] ? val[0].name : "";
        this.queryParams.seriesName = val[1] ? val[1].name : "";
        this.queryParams.modelName = val[2] ? val[2].name : "";
      } else {
        this.queryParams.brandName = "";
        this.queryParams.seriesName = "";
        this.queryParams.modelName = "";
      }
      this.$forceUpdate();
    },

    //列表
    async handleList() {
      this.loading = true;
      try {
        const res = await apis.getList(this.queryParams);
        this.dataList = res.rows;
        this.total = res.total;
      } catch (e) {
        console.error("获取失败", e);
      } finally {
        this.loading = false;
      }
    },

    //新增
    handleNew() {
      this._toPage({
        path: "/VehicleDisposal/RentPurchaseTransfer/PurchaseHandleNew",
        name: 'PurchaseHandleNew',
        query: {
          type: "edit",
        }
      })
    },

    //查看
    handleView() {
      this._toPage({
        path: "/VehicleDisposal/RentPurchaseTransfer/PurchaseHandleDetails",
        name: 'PurchaseHandleDetails',
        query: {
          type: "view",
        }
      })
    },

    //导出
    handleDerive() {
      this.download(
          "/lease/carLeasePurchaseTransfer/export",
          {
            ...this.queryParams,
          },
          `车辆租购过户列表_${new Date().getTime()}.xlsx`
      );
    }
  },
};
</script>

<style scoped lang=""></style>


